package com.topnav.mc.admin.entity.wrapper;

import com.topnav.mc.admin.entity.param.GbServerParam;
import com.topnav.mc.base.mc.McLbWrapper;
import org.springframework.util.StringUtils;

public class GbServerLbWrapper extends McLbWrapper<GbServerParam> {
    public GbServerLbWrapper(GbServerParam entity) {
        super(entity);
        if (entity!=null){
            System.err.println(entity.getKeyword());
            if (entity.getId() != null){this.eq(GbServerParam::getId,entity.getId());}
            if (!StringUtils.isEmpty(entity.getCode())){this.like(GbServerParam::getCode,entity.getCode());}
            if (!StringUtils.isEmpty(entity.getName())){this.like(GbServerParam::getName,entity.getName());}
            if (!StringUtils.isEmpty(entity.getHost())){this.like(GbServerParam::getHost,entity.getHost());}
            if (!StringUtils.isEmpty(entity.getDomain())){this.like(GbServerParam::getDomain,entity.getDomain());}
            if (!StringUtils.isEmpty(entity.getKeyword())){
                this.and(wrapper -> wrapper.like(GbServerParam::getCode, entity.getKeyword())
                        .or().like(GbServerParam::getName, entity.getKeyword())
                        .or().like(GbServerParam::getHost, entity.getKeyword())
                );
/*

                this.like(GbServerParam::getCode,entity.getKeyword())
                        .or()
                        .like(GbServerParam::getName,entity.getKeyword())
                        .or()
                        .like(GbServerParam::getHost,entity.getKeyword());
*/

            }
        }
    }
}
